package com.medicinemanager.ui;

import com.example.medicinemanager.R;
import com.medicinemanager.control.DoubleClickExit;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends BaseActivity {
	private DoubleClickExit mDoubleClickExit = null;
	private OnClickListener mOnClickListener = null;
	private Button mBtnManagerStaff = null;
	private Button mBtnManagerMedicine = null;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        initAction();
        initButton();
    }
    
    private void initButton(){
    	//TODO
    	mOnClickListener = new MyOnClickListener();
    	
    	mBtnManagerStaff = (Button) findViewById(R.id.btn_manager_staff);
    	mBtnManagerStaff.setOnClickListener(mOnClickListener);
    	mBtnManagerMedicine = (Button) findViewById(R.id.btn_manager_medicine);
    	mBtnManagerMedicine.setOnClickListener(mOnClickListener);
    }
    
    private void initAction(){
    	mDoubleClickExit = new DoubleClickExit(MainActivity.this);
    }

	public void gotoBack() {
		mDoubleClickExit.exitApp();
	}

	public void gotoAhead() {
		
	}
	class MyOnClickListener implements OnClickListener{
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			if(v.getId() == mBtnManagerStaff.getId()){
				gotoManagerStaff();
			}
			if(v.getId() == mBtnManagerMedicine.getId()){
				gotoManagerMedicine();
			}
		}
	}
	
	private void gotoManagerMedicine(){
		Intent intent = new Intent();
		intent.setClass(MainActivity.this, ManagerMedicineActivity.class);
		MainActivity.this.startActivity(intent);
	}
	private void gotoManagerStaff(){
		Intent intent = new Intent();
		intent.setClass(MainActivity.this, ManagerStaff.class);
		MainActivity.this.startActivity(intent);
	}
}
